/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entreprise;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import mapping.DBReservation;

/**
 *
 * @author Quoc-Khai
 */
public class ReservationService {
    public Reservation getReservation(String reservationID){
        DBReservation dBReservation=new DBReservation();
        Reservation reservation=null;
        reservation=dBReservation.getReservation(reservationID);
        return reservation;
    }            
    public boolean createReservation(String reservationID, String patientName, String patientPhoneNumber, String patientEmail, Date reservationTime, String require){
        DBReservation dbReservation = new DBReservation();
        Reservation iReservation = new Reservation();
        iReservation.setPatientName(patientName);
        iReservation.setPatientPhoneNumber(patientPhoneNumber);
        iReservation.setPatientEmail(patientEmail);
        iReservation.setReservationTime(reservationTime);
        iReservation.setRequire(require);
        if(dbReservation.createReservation(iReservation)){
            return true;
        }else{
            return false;
        }
    }
    public boolean deleteReservation(String reservationID){
        DBReservation dbReservation = new DBReservation();
        Reservation iReservation = dbReservation.getReservation(reservationID);
        if (iReservation!=null) {
            dbReservation.deleteReservation(reservationID);
            return true;
        }        
//        System.out.println("Reservation not existe!");
        return false;
    }
    public boolean updateReservation(String reservationID, String patientName, String patientPhoneNumber, String patientEmail, Date reservationTime, String require){
        DBReservation dbReservation = new DBReservation();
        Reservation iReservation = dbReservation.getReservation(reservationID);
        if (iReservation!=null) {
            iReservation.setReservationID(reservationID);
            iReservation.setPatientName(patientName);
            iReservation.setPatientPhoneNumber(patientPhoneNumber);
            iReservation.setPatientEmail(patientEmail);
            iReservation.setReservationTime(reservationTime);
            iReservation.setRequire(require);            
            dbReservation.updateReservation(iReservation);
            return true;
        }        
//        System.out.println("Reservation not existe!");
        return false;
    }
    public List<Reservation> findReservations(String reservationName){
        List<Reservation> reservations=null;
        return reservations;
    }
    public ArrayList<Reservation> reservations(){
        DBReservation dBReservation=new DBReservation();
        ArrayList<Reservation> reservations=dBReservation.getReservations("");
        return reservations;
    }
}
